home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d13
/
nuf210.arc
/
NUFIND.DOC
< prev
next >
Wrap
Text File
|
1990-06-14
|
29KB
|
636 lines
NUFIND - A Unix FIND Work Alike
Version 2.1.0: June 13, 1990
Author: Don A Williams
CompuServ - 75410,543
GEnie - DON-WILL
********************* NOTICE ************************
* Contrary to the current trend in MS-DOS software *
* this program, for whatever it is worth, is NOT *
* copyrighted (with the exception of the runtime *
* library from the C compiler)! The program, in *
* whole or in part, may be used freely in any *
* fashion or environment desired. If you find this *
* program to be useful to you, do NOT send any *
* contribution to the author; in the words of Rick *
* Conn, 'Enjoy!' However, if you make any *
* improvements, I would enjoy receiving a copy of *
* the modified source. I can be reached, usually *
* within 24 hours, by messages on any of the *
* following Phoenix, AZ systems (the Phoenix systems *
* can all be reached through StarLink node #9532): *
* *
* The Tool Shop BBS [PCBOARD] [PC-Pursuit] *
* (602) 279-2673 1200/2400/9600 bps *
* Technoids Anonymous [PCBOARD] *
* (602) 899-4876 300/1200/2400 bps *
* (602) 899-5233 *
* (602) 786-9131 *
* Inn On The Park [PCBOARD] *
* (602) 957-0631 1200/2400/9600 bps *
* Pascalaholics Anonymous [WBBS] *
* (602) 484-9356 1200/2400 bps *
* *
* or: *
* Blue Ridge Express [RBBS] Richmond, VA *
* (804) 790-1675 2400 bps [StarLink #413] *
* *
* The Lunacy BBS [PCBOARD] Van Nuys, CA *
* (805) 251-7052 2400/9600 [StarLink 6295] *
* (805) 251-8637 2400/9600 [StarLink 6295] *
* *
* or: *
* GEnie, mail address: DON-WILL *
* CompuServ: 75410,543 *
* *
* Every effort has been made to avoid error and *
* moderately extensive testing has been performed *
* on this program, however, the author does not *
* warrant it to be fit for any purpose or to be *
* free from error and disclaims any liability for *
* actual or any other damage arising from the use *
* of this program. *
*******************************************************
NUFIND, Version 2.1.0, consists entirely of original code or original
modifications of public domain code, replaces earlier versions of
UFIND, 1.0 through 4.0, which were derived from Russell Nelson's
FINDNEW. NUFIND is a "work alike" for the Berkley Unix FIND command
with modifications and enhancements for the PC/MS-DOS environment. It
is a very powerful disk maintenance program with really ugly syntax!
In the Unix world, it seems to be used mostly in aliases and shell
scripts and in the PC/MS-DOS world, I use it mostly in CED synonyms.
Basically, NUFIND will "walk" one or more directory hierarchies,
selecting files according a possibly complex set of specified
selection criteria, and executing any of several "actions" on each
such file selected. Among the "actions" that may be specified are:
delete the file, move the file from one place in the hierarchy to
another, copy the file from one place in the hierarchy to another,
move a sub-hierarchy (a directory and all subordinate directories and
files) from one place in the hierarchy to another, print the full or
relative pathname of each file selected, and execute a specified
command one each selected file. If a "move" action is specified and
both the source and destination are on one drive, NUFIND will perform
a true "move", i.e. only the directory entries will be moved, not the
file content. If a "move" is specified and the source and destination
are on different drives, NUFIND will "automatically" perform a copy
followed by a delete of the source file.
With the increasing popularity of Unix on AT class systems and my
intense frustration with the severely reduced capability of the FIND
of AT&T's System V Release 3, NUFIND will be ported to Unix, probably
before it is ported to other PC-based C compilers.
NOMENCLATURE:
In the following discussion, "absolute pathname" will mean a standard
PC/MS-DOS pathname, including the directories and drive specifier,
e.g. "c:\tc\ufind\ufind.c" is a pathname. The term "relative
pathname" will mean that portion of the "absolute pathname" following
the "current directory", e.g "ufind\ufind.c" would be the "relative
pathname of the preceding file if the "current directory" were
"c:\tc". The term "filename" will refer to the terminal element in a
relative or absolute pathname, e.g. "ufind.c" would be the "filename"
of the preceding file.
Items shown in brackets are optional and need not be supplied (the
brackets are not entered), e.g. "-n[ame]" means that either "-name" or
"-n" will be accepted as meaning the same thing. An expression such
as "filename ..." indicates that one or more file names may be
supplied but at least one must be supplied. The expression,
"[filename ...]" would indicate that no filenames must be specified
but that any number may be.
USAGE:
The command syntax for NUFIND is:
NUFIND [search paths] [selection criteria] [actions]
The default search path is the "current" directory, the default
selection criterion is all files, and the default action is to print
the full path name so that a simple command of:
NUFIND
would list the full path name of every file in the "current" directory
and all subordinate directories.
Search Paths:
The search paths, which must be specified before any other arguments,
may be either relative path names or absolute path names and may
contain a drive specifier. There is no limit on the number of search
paths that may be specified other than the constraints of memory.
Examples:
NUFIND \
this search path will cause NUFIND to search the entire hierarchy
of the "current" drive, starting from the root ("\").
NUFIND .
this search path will cause NUFIND to search the hierarchy
starting with the "current" directory.
NUFIND c:\ d:\ e:\
this search path will cause NUFIND to search the entire
hierarchies of drives C, D, and E, starting with the root on each
drive. For convenience on PC/MS-DOS systems, NUFIND will allow
the specification of multiple device codes for the same path. For
example:
NUFIND cde:\
would be the same as:
NUFIND c:\ d:\ e:\
NUFIND \tc d:\arc
this search path will cause NUFIND to search the directory, "tc"
on the "current" drive and all of its subordinates, and the
directory "arc" on drive D and all of its subordinates.
SELECTION CRITERIA:
The selection criteria are usually, but not necessarily, specified
immediately after the search path specification(s). Actually, only
the search path specifications are positional in the current version
of NUFIND, all other arguments may be specified in any order.
-n[ame] filename ...
Any file in the searched hierarchy whose name matches one of the
names in the list of filenames specified by the -name option will
be selected. The wild card characters "*" and "?" may be included
in any of the specified filenames and they will handled by NUFIND
just as they are handled by the DOS DIR command; i.e. "*" and
"*.*" will match all files, "*.abc" will match any file with an
extension of "abc", "*." will match any file that does not have an
extension. The "?", as in DOS, will match any single character.
Due to the limitation on command line length in PC/MS-DOS (128
bytes), two special forms of the -name option are provided:
-n[ame] -
If the -name argument is followed by a '-', the list of file names
will be read from stdin, one filename per line. The list will be
terminated by end of file on stdin or by a null line in stdin.
-n[ame] @pathname
If the -name argument if followed by a pathname with an '@'
prefix, the list of file names will be read from pathname, one
name per line. The list will be terminated by end of file.
If no -n[ame] argument is specified, NUFIND will assume "*.*" -
all files.
-^n[ame] filename ...
Any file in the searched hierarchy whose name matches one of the
names in the list specified by "-^n[ame]" will be excluded from
the selection. As with the "-n[ame]" list, the filenames in the
"-^name" list may contain the PC/MS-DOS wild card characters and
the two special forms, "-^n[ame] -" and "-^n[ame] @pathname" are
provided for the "-^n[ame]" list with the same meanings as for the
"-n[ame]" list.
-f[name] pathname ...
Any file in the searched hierarchy whose full pathname matches one
of the pathnames specified in the "-fn[ame]" list will be
selected. the pathnames in the "-fn[ame]" list may be absolute or
relative pathnames and may contain the PC/MS-DOS wild card
characters in their filename portion. The two special forms,
"-fn[ame] -" and "-fname @filename" are provided for the
"-fn[ame]" list with the same meanings as before.
-^fn[ame] pathname ...
Any file in the searched hierarchy whose full pathname matches one
of the pathnames in the "-^fn[ame]" list will be excluded from the
selection. As for the "-fn[ame]" list, the pathnames in the
"-^fname" list may be either absolute or relattive pathnames. The
two special forms, "-^fn[ame] -" and "-^fn[ame] @filename" are
provided for the "-^fn[ame]" list with the same meanings as
before.
-attr attributes
Any file in the searched hierarchies whose attributes match those
specified will be selected. The attributes that may be specified
are: "S" for System files, "R" for Read-Only files, "H" for Hidden
files, "A" for files with the "Archive" attribute ON, "D" for
Directories, and "V" for Volume label. For example:
NUFIND -attr shr
would list all files in the hierarchy, starting with the current
directory, that have either the "System" attribute, the "Hidden"
attribute, or the "Read-Only" attribute.
-^attr attributes
Any file in the searched hierarchies that does not have one of the
specified attributes would be listed. For example:
NUFIND -^attr a
would list all files in the hierarchy, starting with the current
directory, whose "Archive" attribute was OFF.
-si [date]
Any file in the searched hierarchies whose date is greater than or
equal to the specified date would be listed. If no date is
specified, the "current" date from PC/MS-DOS will be used. The
date may be entered in any of several forms: "mm/dd/yy",
"yy/mm/dd", "mmddyy", "yymmdd", "mm-dd-yy", or "yy-mm-dd". The
year may be either the 2-digit form or the 4-digit form. For
example:
NUFIND -si
would list all files in the hierarchy, starting with the current
directory, that have been created or modified "today".
Unix maintains three dates for a file, the "changed" date, the
"modified" date, and the "accessed" date. When NUFIND is ported
to Unix, the "-si" option will be expanded to three options:
"-sia", "-sic", and "-sim" to cover the three possible dates.
-be [date]
Any file in the searched hierarchies whose date is less than the
specified date would be listed. As for "-si", if no date is
specified, the "current" date from PC/MS-DOS will be used. The
date may be entered in any of the forms supported by the "-si"
option. For example:
NUFIND \ -be 01/01/88
would list all files on the current disk that were created or last
modified prior to January 1, 1988.
The "-si" and "-be" options can be used together. For example:
NUFIND \ -si 01/01/88 -be 01/01/89
would select all files on the current disk that were created or
modified in the year 1988.
-size [-]size_in_bytes
Any file in the searched hierarchies whose size, in bytes, is
greater than or equal to the specified size would be listed. If
the specified size is negative, any file in the searched
hierarchies whose size in bytes is less than or equal to the
specified size would be selected. For example:
NUFIND -size 1000
would list all files in the hierarchy, starting with the current
directory, that were 1,000 bytes or larger, and:
NUFIND \ -size -1000
would list all files on the current disk that were 1,000 bytes or
smaller.
NUFIND cde: -size 1000000
would list all files on drives C, D, and E that were 1 meg or
larger.
-lt path_name
Any file in the searched hierarchies whose Date/Time is less
(earlier) than that of the specified file would be listed.
-le path_name
Any file in the searched hierarchies whose Date/Time is less than
(earlier) or equal to that of the specified file would be
selected.
-gt path_name
Any file in the searched hierarchies whose Date/Time is greater
(later) than that of the specified file would be selected.
-ge path_name
Any file in the searched hierarchies whose Date/Time is greater
(later) or equal to that of the specified file would be selected.
I have not found much use for the "-lt", "-le", "-gt", or "-ge"
options. The "-gt" could be used with a backup program that
maintained as disk log and would accept files to back up from
standard input, such as the Unix cpio command or Raoul Dehsi's
ZOO. For example:
NUFIND \ -gt \backup.zoo | zoo aI \backup.zoo
would add all files that had been create or modified since the
last "backup" to the file, "backup.zoo". Unfortunately, I know of
no PC/MS-DOS backup program that accepts a list of files from
standard input.
-ltdate path_name
Any file if the searched hierarchies whose Date (Time would be
ignored) was less (earlier) than that of the specified file would
be selected.
-ledate path_name
Any file in the searched hierarchies whose Date (Time would be
ignored) was less (earlier) than or equal to that of the specified
file would be selected.
-gtdate path_name
Any file in the searched hierarchies whose Date (Time would be
ignored) was greater (later) than that of the specified file would
be selected.
-gedate path_name
Any file in the searched hierarchies whose Date (Time would be
ignored) was greater (later) than or equal to that of the
specified file would be selected.
I have found no real use for "-ltdate", "-ledate", "-gtdate", or
"-.gedate".
-exist directory_path_name
Any file in the searched hierarchies would be selected if there
was a file in the specified directory with the same name and
extension.
-^exist directory_path_name
Any file in the searched hierarchies would be selected only if
there was no file in the specified directory with the same name
and extension.
-comp directory_path_name
Any file in the searched hierarchies would be selected if there
was a file in the specified directory with the same name and
extension and the sizes and the Date/Time of the two files were
the same.
-^comp directory_path_name
Any file in the searched hierarchies would be selected only if
there was a file in the specified directory with the same name and
extension and the files had different sizes or Date/Times.
ACTIONS:
NUFIND provides a number of "actions" that can be applied,
individually or in combinations, to each of the files that meet the
above selection criteria. The default action is to print the full
path name, including disk specifier, to standard output. The Unix
FIND prints the relative path name, however, on PC/MS-DOS, I have
found the full path name to be more useful. NUFIND provides and
option, "-re", that will cause it to print the relative path names
instead of the full path names for those few instances were the
relative path name is more useful.
-p
Although the default action is to print the names of the selected
files, if any other action is specified, the printing of the file
names will be suppressed unless the "-p" option is also specified.
-re
Causes NUFIND to print the relative path names of the selected
files instead of the full path name.
-s
Suppresses all printing from NUFIND. "-s" and any of the other
actions that cause or effect printing are incompatible.
-sum
Causes NUFIND to print out the sum of the sizes of all selected
files. For example:
NUFIND \ -n *.arc -sum
would list all files on the current disk that have the "ARC"
extension and would show the total of the sizes of all such files.
-ls
Causes NUFIND to list the attributes, size, Date/Time, and full
path name of each selected file in a form similar to that of the
Unix ls command. For example, on my C: drive, the command:
NUFIND C:\TC\NUFIND -ls
produces the following listing:
-d---w 14-Nov-88 4:44 c:\tc\nufind\arc
a----w 22,539 24-Sep-88 12:04 c:\tc\nufind\ufind.doc
a----w 5,442 7-Nov-88 4:50 c:\tc\nufind\find.man
a----w 348 13-Nov-88 4:20 c:\tc\nufind\queue.h
a----w 583 14-Nov-88 4:42 c:\tc\nufind\makefile
a----w 62 14-Nov-88 4:42 c:\tc\nufind\nufind.prj
a----w 991 24-Nov-88 4:21 c:\tc\nufind\isdev.c
a----w 1,145 24-Nov-88 4:21 c:\tc\nufind\queue.c
a----w 1,106 24-Nov-88 4:21 c:\tc\nufind\getcurd.c
a----w 3,833 24-Nov-88 4:21 c:\tc\nufind\fullpath.c
a----w 407 24-Nov-88 4:22 c:\tc\nufind\nufind.h
a----w 3,231 26-Nov-88 4:25 c:\tc\nufind\copy.c
a----w 1,690 31-Dec-88 4:41 c:\tc\nufind\tcconfig.tc
a----w 1,196 31-Dec-88 4:45 c:\tc\nufind\tcpick.tcp
a----w 9,501 31-Dec-88 5:34 c:\tc\nufind\nufind.c
a----w 7,669 31-Dec-88 5:38 c:\tc\nufind\select.c
a----w 17,816 31-Dec-88 5:39 c:\tc\nufind\getargs.c
a----w 25,548 31-Dec-88 5:39 c:\tc\nufind\nufind.exe
a----w 74 31-Dec-88 5:40 c:\tc\nufind\makezoo.bat
a----w 1,373 31-Dec-88 6:46 c:\tc\nufind\args
a----w 16,046 1-Jan-89 5:19 c:\tc\nufind\nufind.doc
a----w 48,524 31-Dec-88 5:40 c:\tc\nufind\arc\nufind01.zoo
I believe that the fields, with the exception of the attributes
field, are self-explanatory. The attributes field has a position
for each of the seven possible PC/MS-DOS attributes:
advshw
where "a" indicates that the "Archive" attribute is ON. A "-" in
this position would indicate that the "Archive" attribute is OFF.
The "d" indicates a directory. This position will be a "-" for
files or volume labels. The "v" indicates a volume label. This
position will be a "-" for files and directories. The "s"
indicates that the "System" attribute is ON. A "-" in this
position would indicate that the "System" attribute was OFF. The
"h" indicates that the "Hidden" attribute is ON. A "-" in this
position would indicate that the "Hidden" attribute was OFF.
Finally, the "w" indicates that the file can be written, i.e the
"Read-Only" attribute is OFF. A "-" in this position would
indicate that the file was "Read-Only".
-ld
This action is the same as "-ls" except that the Date field is
printed in format compatible with machine sorting. For example,
the prior command except with "-ld" instead of "-ls" would produce
the following listing:
-d---w 88-11-14 4:44 c:\tc\nufind\arc
a----w 22,539 88-09-24 12:04 c:\tc\nufind\ufind.doc
a----w 5,442 88-11-07 4:50 c:\tc\nufind\find.man
a----w 348 88-11-13 4:20 c:\tc\nufind\queue.h
a----w 583 88-11-14 4:42 c:\tc\nufind\makefile
a----w 62 88-11-14 4:42 c:\tc\nufind\nufind.prj
a----w 991 88-11-24 4:21 c:\tc\nufind\isdev.c
a----w 1,145 88-11-24 4:21 c:\tc\nufind\queue.c
a----w 1,106 88-11-24 4:21 c:\tc\nufind\getcurd.c
a----w 3,833 88-11-24 4:21 c:\tc\nufind\fullpath.c
a----w 407 88-11-24 4:22 c:\tc\nufind\nufind.h
a----w 3,231 88-11-26 4:25 c:\tc\nufind\copy.c
a----w 1,690 88-12-31 4:41 c:\tc\nufind\tcconfig.tc
a----w 1,196 88-12-31 4:45 c:\tc\nufind\tcpick.tcp
a----w 9,501 88-12-31 5:34 c:\tc\nufind\nufind.c
a----w 7,669 88-12-31 5:38 c:\tc\nufind\select.c
a----w 17,816 88-12-31 5:39 c:\tc\nufind\getargs.c
a----w 25,548 88-12-31 5:39 c:\tc\nufind\nufind.exe
a----w 74 88-12-31 5:40 c:\tc\nufind\makezoo.bat
a----w 1,373 88-12-31 6:46 c:\tc\nufind\args
a----w 18,862 89-01-01 5:35 c:\tc\nufind\nufind.doc
a----w 1,400 89-01-01 5:20 c:\tc\nufind\notes
a----w 48,524 88-12-31 5:40 c:\tc\nufind\arc\nufind01.zoo
-nr
By default, NUFIND searches each of the specified paths
recursively until it finds no more directories. The "-nr" (No
Recursion) option inhibits this recursive search. For example:
NUFIND \
would list all of the files and directories in all of the
directories on the current disk where:
NUFIND \ -nr
would list only the files and directories in the root.
-rm
This option removes (deletes) the selected files, for example:
NUFIND cde: -n *.bak *.tmp *.err -rm
would delete all files with a "BAK", a "TMP", or a "ERR" extension
on disks C, D, and E.
Normally, NUFIND will NOT delete a file with "Read-Only"
attributes, however, there is an option that will cause it to
remove such files also, "-rma" for "remove all"
-rmdir
This option removes (deletes) directories. For example:
NUFIND \trash -rm -rmdir
would delete the directory, "TRASH", (assuming that "TRASH" was
not the "current" directory) and all subordinate directories and
files. I have a CED synonym on my system called "KILL" that is:
SYN KILL NUFIND %1 -rm -rmdir
that I use to remove directories.
-kill
This option is short hand for "-rm "-rmdir". It will removes all
files and subordinate directories in the source directory. It
eliminates the need for a "KILL" CED synonym. This is a VERY
dangerous operation!!
-attr+ attribute(s)
This option turns ON the specified attribute(s) for all selected
items. For example:
NUFIND \ -n *.arc -attr+ h
would make all files with the "ARC" extension on the current disk
"Hidden".
-attr- attribute(s)
This option turns OFF the specified attribute(s) for all selected
items. For example:
NUFIND \ -n *.exe *.com -attr- w
would make all EXE and COM files on the current disk "Read-Only".
-cp directory_path_name
This option causes all selected files to be copied to the
specified directory. If the destination directory does not exist,
NUFIND will create it. If a file with the same name as a file to
copied already exists in the destination directory, NUFIND will
warn the user and present the options of overwriting the existing
file or skipping the copy of that file. Without the '-t' option,
'-cp' will not create subordinate directories in the destination
directory, all files from all directories in the source will be
copied to the single level destination directory. The Date/Time |
of the copied files will be "today" and the time at which they |
were copied. |
-cpo directory_path_name |
This option is the same as '-cp' above except that the copied |
files will have the same Date/Time as the originals. |
-ct directory_path_name
This option is short hand for "-t -cp". It will copy the tree
structure, including all subordinate directories, from the source
directory to the destination directory. As with the '-cp' option, |
the copied files will have a Date/Time of "today" and the time at |
which they were copied. |
-cto directory_path_name |
This option is the same as '-ct' above except that the copied |
files will have the same Date/Time as the originals. |
-mv directory_path_name
This option causes all selected items to be "moved" to the
specified directory. If the destination directory is on the same
disk as the source, only the entries in the directories are move,
not the full content. If the destination directory is NOT on the
same disk as the source, the files are copied and the source file
is deleted. The "-mv" action will also create the destination
directory if necessary and handles potential overwrites in the
same fashion as the "-cp" action. Like the "-cp" option, "-mv"
does not create subordinate directories in the destination
directory. Unlike the '-cp' option, files "moved" with the '-mv' |
retain their original Date/Time. |
-mt directory_path_name
This option is short hand for "-t -mv". It will move the source
tree structure, including all subordinate directories, to the
destination directory. Like the '-mv' option, files "moved" with |
the '-mt' option retain their original Date/Time. |
-t
This option affects the "-cp" and "-mv" actions only. Normally,
when a file is moved or copied by NUFIND, only the file name and
extension are abstracted from the source path name and appended to
the destination directory to create the new file path name. For
example, if the following command were issued:
NUFIND \tc -cp \turboc
and there was a file, say, \tc\arc\nufind.arc, it would be copied
to \turboc\nufind.arc. The "-t" option modifies this action so
that the path name, relative to the source directory, is appended
to the destination directory to form the new path name. In the
prior example, if the command were:
NUFIND \tc -cp \turboc -t
the file, \tc\arc\nufind.arc would be copied to
\turboc\arc\nufind.arc. Both the "-cp" and "-mv" actions will
create any necessary directories in the destination.
The options "-ct" and "-mt" are short hand options for "-t -cp"
and "-t -mv" respectively.